<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="txt">
    <button id="but">点击</button>
    <input type="text" id="txt1">
</body>
</html>
<script>
        but.onclick = function(){
            var num1;
            var num2 = 1
            for(var i = 0;i < txt.value;i++){
                num1 = txt.value - i
                num2 *= num1
            }
            txt1.value = num2
        }
    </script>